﻿Imports X360.STFS
Imports System.IO

    Module resigner

        ' NOTE: The X360 Library is protected under a specific Terms and Service and License
        '
        ' Make sure you read that before doing anything, mainly because it REQUIRES you
        '
        ' To make everything open source and NOT make profit off it

        Friend Sub OpenResign(ByVal sender As Object, ByVal e As EventArgs)
        Dim xPackage As New STFSPackage(sender.ToString, Nothing) 'sender)
        If Not xPackage.ParseSuccess Then
            xPackage.CloseIO()
            Exit Sub
        Else
            If File.Exists(Application.StartupPath & "\Resources\KV.bin") Then
                success = xPackage.FlushPackage(New RSAParams(Application.StartupPath & "\Resources\KV.bin"))
                If success = True Then
                    xPackage.CloseIO()
                Else
                    Main.LogListBox.Items.Add("   Error Resigning " & Main.SavesListView.Items(Main.counter).Text)
                    Main.LogListBox.SelectedIndex = Main.LogListBox.Items.Count - 1
                    Main.LogListBox.SelectedIndex = -1
                    Main.ErrorCount += 1
                End If

                Main.LogListBox.Items.Add("   Resigned " & Main.SavesListView.Items(Main.counter).Text)
                Main.LogListBox.SelectedIndex = Main.LogListBox.Items.Count - 1
                Main.LogListBox.SelectedIndex = -1
                Main.ResignCount += 1

            Else
                Main.LogListBox.Items.Add("   KV.bin is missing, cannot resign")
                Main.LogListBox.SelectedIndex = Main.LogListBox.Items.Count - 1
                Main.LogListBox.SelectedIndex = -1
            End If
        End If
    End Sub
    End Module
